﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Schema;

namespace TISS_Add_in
{
    public partial class uc_Validacao : UserControl
    {
        ImageList imgList = new ImageList();

        public uc_Validacao(List<ValidationInfo> itemList)
        {
            InitializeComponent();
            PopulateListview(itemList);
            listViewValidation.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
        }

        public uc_Validacao(ValidationInfo info)
        {
            InitializeComponent();
            PopulateListview(info);
            listViewValidation.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
        }

        private void PopulateListview(List<ValidationInfo> itemList)
        {
            ListViewItem validationInfoItem = null;
            string[] validationInfodata = new string[2];
            if (itemList != null && itemList.Count > 0)
            {
                foreach (ValidationInfo item in itemList)
                {
                    validationInfodata[0] = item.FieldName;
                    validationInfodata[1] = item.Message;
                    validationInfoItem = new ListViewItem(validationInfodata, 0);
                    listViewValidation.Items.Add(validationInfoItem);
                }
            }
        }

        private void PopulateListview(ValidationInfo info)
        {
            string[] validationInfodata = new string[2];
            validationInfodata[0] = info.FieldName;
            validationInfodata[1] = info.Message;

            ListViewItem validationInfoItem = new ListViewItem(validationInfodata, 0);
            
            listViewValidation.Items.Add(validationInfoItem);
        }
    }
}
